package com.aierjun.ani.dialog;

import android.app.Dialog;
import android.content.Context;
import android.support.annotation.NonNull;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.aierjun.ani.R;
import com.nostra13.universalimageloader.core.ImageLoader;

/**
 * Created by Ani_aierJun on 2017/10/11.
 */

public class BigImageViewDialog extends Dialog {

    private Context mContext;
    private ImageView imageView;

    public BigImageViewDialog(@NonNull Context context) {
        super(context, R.style.style_dialog);
        mContext = context;
        imageView = new ImageView(context);
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        imageView.setLayoutParams(layoutParams);
        imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dismiss();
            }
        });
    }

    public void showView(String url) {
        if (imageView == null){
           new BigImageViewDialog(mContext);
        }
        ImageLoader.getInstance().displayImage(url, imageView);
        setContentView(imageView);
        show();
    }

}
